home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 48 / Amiga Format CD48 (1999-12-13)(Future Publishing)(GB)(Track 1 of 2)[!][issue 2000-01].iso / -in_the_mag- / networking / crosspc / parpc04 / hardware / src / talk.c < prev   
C/C++ Source or Header  |  1993-08-12  |  1KB  |  54 lines

  1. /* TALK.C: To test sending from PC to amiga
  2.  * 1. on your amiga, type: machaddr 5
  3.  *                         listen 4
  4.  * 2. on the PC, type:     talk 5 4
  5.  * (port & destination addresses can ofcourse be changed)
  6.  */
  7. #include <stdio.h>
  8. #include <signal.h>
  9. #include "pardev.h"
  10.  
  11. Header hdr;
  12.  
  13. void ParAbort(void)
  14. {
  15.   par_stop();
  16.   printf("Aborted.\n");
  17.   exit(1);
  18. }
  19.  
  20. /* for talking are interrupts not really needed */
  21. int parint(int dev)
  22. {
  23. }
  24.  
  25. main(int argc,char **argv)
  26. {
  27.  unsigned int dest,port;
  28.  unsigned long count;
  29.  int length;
  30.  unsigned char buffer[8]="12345678"; /* just something to fill it */
  31.  
  32.  par_init(1,LPTADDR);
  33.  ctrlbrk(ParAbort);
  34.  
  35.  dest=atoi(argv[1]);
  36.  port=atoi(argv[2]);
  37.  
  38.  printf("Sending something to destination %d port %d\n",dest,port);
  39.  
  40.  /* fill the PARnet header */
  41.  put16((char *)&hdr.port,port);
  42.  hdr.chksum = 0;
  43.  put32((char *)&hdr.length,8);
  44.  
  45.  /* writing buffer to line */
  46.  for (count=0;count<65535;count++)
  47.  { 
  48.   sprintf(buffer,"%08lu",count);
  49.   length=parwriteV(dest,&hdr,sizeof(hdr),buffer,8,NULL,NULL);
  50.   printf("WROTE %08lu LENGTH %d\n",count,length);
  51.  }
  52.  ParAbort();
  53. }
  54.